package com.jpress.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

@Entity
@Table(name="parametro")
@NamedQueries({ 
	@NamedQuery(name="Parametro.findByChave", query="SELECT p FROM Parametro p WHERE p.chave = :chave"),
	@NamedQuery(name="Parametro.findAll", query="SELECT p FROM Parametro p"),
	@NamedQuery(name="Parametro.pesquisar", query="SELECT p FROM Parametro p WHERE p.chave LIKE :chave AND p.descricao LIKE :descricao AND p.valor LIKE :valor")
})
public class Parametro {
	
	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE)
	@Column(name="codigo", unique=true, nullable=false)
	private short codigo;
	
	@Column(name="chave", unique=true, nullable=false, length=100)
	private String chave;
	
	@Column(name="descricao", nullable=false, length=255)
	private String descricao;
	
	@Column(name="valor", nullable=false, length=255)
	private String valor;

	public Parametro(){}
	
	public Parametro(String descricao, String valor) {
		super();
		this.descricao = descricao;
		this.valor = valor;
	}
	
	public short getCodigo() {
		return codigo;
	}

	public void setCodigo(short codigo) {
		this.codigo = codigo;
	}

	public String getChave() {
		return chave;
	}

	public void setChave(String chave) {
		this.chave = chave;
	}	

	public String getDescricao() {
		return descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}
	
	public String getValor() {
		return valor;
	}

	public void setValor(String valor) {
		this.valor = valor;
	}

	@Override
	public boolean equals(Object parametro){
		return EqualsBuilder.reflectionEquals(this, parametro);
	}

	@Override
	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}
}
